package gold.contest;

import gold.utils.InputUtil;

import java.util.Arrays;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC6133 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int maximumGroups(int[] grades) {
            int sqtNum = (int) (Math.sqrt(2 * grades.length));
            if ((sqtNum + 1) * (sqtNum + 2) <= 2 * grades.length) return sqtNum + 1;
            if ((sqtNum) * (sqtNum + 1) <= 2 * grades.length) return sqtNum;
            else return sqtNum - 1;
        }
    }

    public void run() {
        System.out.println(new Solution().maximumGroups(InputUtil.toIntegerArray("[10,6,12,7,3,5]")));
        System.out.println(new Solution().maximumGroups(InputUtil.toIntegerArray("[10,6]")));
    }

    public static void main(String[] args) throws Exception {
        LC6133 an = new LC6133();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
